package com.school.campus.service.impl;

import java.util.List;

import com.school.campus.domain.Seat;
import com.school.campus.domain.vo.StudyRomDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.school.campus.mapper.StudyRoomMapper;
import com.school.campus.domain.StudyRoom;
import com.school.campus.service.IStudyRoomService;

/**
 * 自习室信息Service业务层处理
 *
 * @author wwj
 * @date 2025-10-31
 */
@Service
public class StudyRoomServiceImpl implements IStudyRoomService {
    @Autowired
    private StudyRoomMapper studyRoomMapper;

    /**
     * 查询自习室信息
     *
     * @param id 自习室信息主键
     * @return 自习室信息
     */
    @Override
    public StudyRoom selectStudyRoomById(Long id) {
        return studyRoomMapper.selectStudyRoomById(id);
    }

    /**
     * 查询自习室信息列表
     *
     * @param studyRoom 自习室信息
     * @return 自习室信息
     */
    @Override
    public List<StudyRoom> selectStudyRoomList(StudyRoom studyRoom) {
        return studyRoomMapper.selectStudyRoomList(studyRoom);
    }

    /**
     * 新增自习室信息
     *
     * @param studyRoom 自习室信息
     * @return 结果
     */
    @Override
    public int insertStudyRoom(StudyRoom studyRoom) {
        studyRoom.setCurrentPeople(0L);
        studyRoom.setReservedPeople(0L);


        studyRoom.setStatus(1L);
        return studyRoomMapper.insertStudyRoom(studyRoom);
    }

    /**
     * 修改自习室信息
     *
     * @param studyRoom 自习室信息
     * @return 结果
     */
    @Override
    public int updateStudyRoom(StudyRoom studyRoom) {
        return studyRoomMapper.updateStudyRoom(studyRoom);
    }

    /**
     * 批量删除自习室信息
     *
     * @param ids 需要删除的自习室信息主键
     * @return 结果
     */
    @Override
    public int deleteStudyRoomByIds(Long[] ids) {
        return studyRoomMapper.deleteStudyRoomByIds(ids);
    }

    /**
     * 删除自习室信息信息
     *
     * @param id 自习室信息主键
     * @return 结果
     */
    @Override
    public int deleteStudyRoomById(Long id) {
        return studyRoomMapper.deleteStudyRoomById(id);
    }

    @Override
    public List<Seat> selectStudyRoomVOById(Long id) {
        return studyRoomMapper.getRoomDetailWithSeats(id);
    }
}
